//
//  MJBirthdayPiker.m
//  module_more
//
//  Created by HappyMilk 02 on 2017/2/10.
//  Copyright © 2017年 HappyMilk 02. All rights reserved.
//

#import "MJBirthdayPiker.h"

@interface MJBirthdayPiker ()

@property (weak, nonatomic) IBOutlet UIDatePicker *datePikerView;
@property (nonatomic, strong) UIView *zhedangView;

@end

@implementation MJBirthdayPiker

- (void)tap:(UIGestureRecognizer *)tap{
    
    NSDateFormatter *dateFormatter=[[NSDateFormatter alloc]init];//创建一个日期格式化器
    dateFormatter.dateFormat=@"yyyy年MM月dd日";//指定转date得日期格式化形式
    NSLog(@"%@",[dateFormatter stringFromDate:self.datePikerView.date]);//2015-11-20 08:24:04
    NSString *str = [dateFormatter stringFromDate:self.datePikerView.date];
    self.chioceBirthday(str);
    [self removeFromSuperview];
    [_zhedangView removeFromSuperview];
}

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        self = [[[NSBundle mainBundle] loadNibNamed:@"MJBirthdayPiker" owner:nil options:nil] lastObject];
        self.backgroundColor = [UIColor whiteColor];
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 5;
        
        
    }
    return self;
}

- (void)showBirthdayPikerViewInView:(UIView*)rootView{
    
    self.zhedangView = [[UIView alloc] initWithFrame:rootView.frame];
    self.zhedangView.backgroundColor = [UIColor blackColor];
    self.zhedangView.alpha = 0.4;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
    [self.zhedangView addGestureRecognizer:tap];
    
    [rootView addSubview:self.zhedangView];
    [rootView addSubview:self];
}

@end
